package myky.com.doctorapp.model;

import java.util.List;
import java.util.concurrent.TimeUnit;

import io.reactivex.Flowable;
import io.reactivex.Observable;
import myky.com.doctorapp.api.ApiManager;
import myky.com.doctorapp.api.Apistore;
import myky.com.doctorapp.api.schedulers.SchedulerHelper;
import myky.com.doctorapp.base.BaseEntity;
import myky.com.doctorapp.contract.MyDoctorContract;
import myky.com.doctorapp.entity.MyDoctorEntity;
import myky.com.doctorapp.utils.RequestBodyBuilder;
import okhttp3.RequestBody;

public class MyDoctorModel implements MyDoctorContract.Model {
    @Override
    public Observable<BaseEntity<List<MyDoctorEntity.DataBean>>> findMyDoctorList(String version, String currentPagae, String pageSize) {

        RequestBodyBuilder.Builder builder = new RequestBodyBuilder.Builder();
        RequestBody requestBody = builder.params("current", currentPagae)
                .params("size", pageSize)
                .params("version", version).build();
        builder.params("current", currentPagae)
                .params("size", pageSize)
                .params("version", version).build();

        return ApiManager.getApistore().getMyDocotor(requestBody).compose(SchedulerHelper.applySchedulers());
    }

    @Override
    public Observable<BaseEntity<Object>> allowedPermission(String casepermission, String doctorId, String version) {

        RequestBodyBuilder.Builder builder = new RequestBodyBuilder.Builder();

        RequestBody requestBody = builder.params("casepermission", casepermission).params("doctorid", doctorId).params("version", version).build();

        return ApiManager.getApistore().allowedPermission(requestBody).compose(SchedulerHelper.applySchedulers());
    }
}
